from typing import List

class Solution:
    def beautifulArray(self, N: int) -> List[int]:
        """
        生成漂亮数组
        
        Args:
            N: 数组长度
            
        Returns:
            漂亮数组
        """
        memo = {1: [1]}
        
        def f(N):
            if N not in memo:
                # 递归生成漂亮数组
                # 奇数部分：2x-1
                # 偶数部分：2x
                memo[N] = [2 * x - 1 for x in f((N + 1) // 2)] + [2 * x for x in f(N // 2)]
            return memo[N]
            
        return f(N) 